<?php

ini_set('display_errors',1);
ini_set('include_path', ini_get('include_path'));

require_once '../../../serverResources/includes/db/ConnDBAdmin.php';
require_once '../../../serverResources/includes/classes/Project.php';
include_once '../others/refreshSessionTime.php';

if(isset($_POST['type']) && isset($_POST['fileName']) && isset($_POST['projectID'])){



	if($_POST['type']=="picture"){

		$pj=new Project('', '', '', '', '', '');
		$path='../../upload/images/' . $_POST['fileName'];
		$deleted=$pj->deletePicture($_POST['fileName'], $path, $_POST['projectID']);
		unset($pj);

		if($deleted){
			echo 1;
		}else{
			echo 0;
		}

	}else if($_POST['type']=="audio"){

		$pj=new Project('', '', '', '', '', '');
		$path='../../upload/audio/' . $_POST['fileName'];
		$deleted=$pj->deleteAudio($_POST['fileName'], $path, $_POST['projectID']);
		unset($pj);

		if($deleted){
			echo 1;
		}else{
			echo 0;
		}

	}else if($_POST['type']=="video"){

		$pj=new Project('', '', '', '', '', '');
		$deleted=$pj->deleteVideo($_POST['fileName'], $_POST['projectID']);
		unset($pj);

		if($deleted){
			echo 1;
		}else{
			echo 0;
		}


	}else if($_POST['type']=="zip"){

		$pj=new Project('', '', '', '', '', '');
		$path='../../upload/zip/' . $_POST['fileName'];
		$deleted=$pj->deleteZIP($_POST['fileName'],$path, $_POST['projectID']);
		unset($pj);

		if($deleted){
			echo 1;
		}else{
			echo 0;
		}

	}else if($_POST['type']=="pdf"){

		$pj=new Project('', '', '', '', '', '');
		$path='../../upload/pdf/' . $_POST['fileName'];
		$deleted=$pj->deletePDF($_POST['fileName'],$path, $_POST['projectID']);
		unset($pj);

		if($deleted){
			echo 1;
		}else{
			echo 0;
		}

	}else if($_POST['type']=="doc"){

		$pj=new Project('', '', '', '', '', '');
		$path='../../upload/doc/' . $_POST['fileName'];
		$deleted=$pj->deleteDOC($_POST['fileName'],$path, $_POST['projectID']);
		unset($pj);

		if($deleted){
			echo 1;
		}else{
			echo 0;
		}
	}


}else{
	echo 0;
}